<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title>CRM系统</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <link rel="stylesheet" href="${ctx}/js/ext-3.3.0/resources/css/ext-all.css"/>
  <link rel="stylesheet" href="${ctx}/css/index_0805.css"/>
  <script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-base.js"></script>
  <script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-all.js"></script>
  <script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-lang-zh_CN.js"></script>
  <style>
  		#logout a{
  			text-decoration: none;
  			color: #15428B;
  		}
  		.titleLabelcss{
  			color: #15428B;
  			padding-left: 120px;
  		}
  </style>
  <script type="text/javascript">
  	var toolbar = null;
	var userId = ${SESSION_USER.id?c};
		var userId ='${SESSION_USER.userName!}';
     Ext.onReady(function(){
    	 var loader =new Ext.tree.TreeLoader({
				dataUrl: "${ctx}/crmright/listmenu?roleIds=${SESSION_USER.roleIds!}"
		    });
     	 var rootNode = new Ext.tree.AsyncTreeNode({
			id : '0',
            children: [{
            	text: '手机后台管理',
                leaf: false
            }]
         });
          var mainpanel = new Ext.Panel({
				margins: '0 0 5 0',
           		region: 'center',
		        xtype: 'panel',
		        id : 'main',
   		        bodyBorder :true,
   		        layout : 'fit',
   		        iconCls : 'house',
		        autoScroll : true,
				title:'首页',
                html: '<iframe id=\'mainframe\' frameborder="0" src=\'${ctx}/right.html\' width=\'100%\' height=\'100%\' height=\"100%\" scrolling=\'auto\'></iframe>'
                //<iframe frameborder="0" id="main" name="main" scrolling="yes" src="/ddmap-mobile-medit/main_info.jsp" style="HEIGHT: 96%; VISIBILITY: inherit; WIDTH: 100%; Z-INDEX: 1"></iframe>
		        //autoLoad : {
			    //    url : '${ctx}/main_info.jsp',
			    //    scope : this,
			   //     scripts : true,
			      //  text : '页面加载中,请稍候/....'
	      		//}
         });
         var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"加载数据中,请等待......",store:loader,removeMask :true});
         toolbar = new Ext.Toolbar({
            items:[
   				"&nbsp;",
				"'欢迎您: ${SESSION_USER.userName!} 你有<a href=''>5条未读信息</a>,<a href=''>5条待处理任务</a>",
				"&nbsp;",
				new Ext.form.Label({
					id:'titleLabel',
					cls :'titleLabelcss',
					html:'手机后台管理  | <span id="logout"><a href="#" onclick="goIndex()">回到首页</a> |  <a href="${ctx}/crmuser/logout" target="_top">退出</a></span>'
				}),"&nbsp;&nbsp;"
			]
		});
			toolbar.items.itemAt(1).text = "'欢迎您1111: ${SESSION_USER.userName!}";
    	 new Ext.Viewport({
		 		id:'viewport',
    		    layout: 'border',
    		    items: [
    		    {
					id:'header',
					region: 'north',
					xtype: 'panel',
					border:false,
					height:25,
					bbar:toolbar
				}
    		    ,
    		    {
    		    	id:'exttreegridid',
    		        region: 'west',
    		        collapsible: false,
					margins: '0 0 5 0',
    		        xtype: 'treepanel',
    		        width: 200,
    		        autoScroll: true,
    		        split: true,
					minSize: 140,
					maxSize: 200,
					lines:false,
					animCollapse:false,
					animate: false,
					collapseMode:'mini',
    		        root: rootNode,
    		        loader:loader,
    		        rootVisible: false,
					title:'菜单',
    		        listeners: {
    		            click: function(n) {
							Ext.getCmp("main").setTitle(n.attributes.text);
							if(n.attributes.parent_code == "0"){
								Ext.getCmp("titleLabel").setText("手机后台管理-" + n.attributes.text + "   | <span id='logout'><a href='#' onclick='goIndex()'>回到首页</a> |  <a href='${ctx}/crmuser/logout' target='_top'>退出</a></span>",false);
								return;
							}else if(n.attributes.parent_code == null){
							     Ext.getCmp("titleLabel").setText("手机后台管理   | <span id='logout'><a href='#' onclick='goIndex()'>回到首页</a> |  <a href='${ctx}/crmuser/logout' target='_top'>退出</a></span>",false);	
								return;
							}
    		            	Ext.getDom("mainframe").contentWindow.location.href = "${ctx}/" + n.attributes.url;
    		            	Ext.getCmp("titleLabel").setText("手机后台管理-" + n.parentNode.text + "-" + n.attributes.text + "   | <span id='logout'><a href='#' onclick='goIndex()'>回到首页</a> |  <a href='${ctx}/crmuser/logout' target='_top'>退出</a></span>",false);
    		            },
						beforeexpandnode: function(n) {
						     if(n.attributes.parent_code == "0"){
								Ext.getCmp("titleLabel").setText("手机后台管理-" + n.attributes.text + "   | <span id='logout'><a href='#' onclick='goIndex()'>回到首页</a> |  <a href='${ctx}/crmuser/logout' target='_top'>退出</a></span>",false);
						     }
						},
						beforecollapsenode:function(n) {
							 Ext.getCmp("titleLabel").setText("手机后台管理   | <span id='logout'><a href='#' onclick='goIndex()'>回到首页</a> |  <a href='${ctx}/crmuser/logout' target='_top'>退出</a></span>",false);	
						},
    		            beforeload:function(node){
   						  Ext.getCmp("exttreegridid").getLoader().baseParams.nodeParentId = node.id;
   						  if(node.parentNode){
   							  Ext.getCmp("exttreegridid").getLoader().baseParams.nodeParentId = node.attributes.code;
   						  }
   		  			   }
    		        }
    		    }, mainpanel]
    		});
    	 rootNode.expandChildNodes(false);
		 toolbar.items.itemAt(1).text = "bbbba>";
		 toolbar.items.itemAt(1).setText("欢迎你,${SESSION_USER.userName}");
		// alert (Ext.getCmp("viewport").items.bbar );
    });  
    function goIndex(){
		Ext.getCmp("main").setTitle("首页");
    	//Ext.getDom("mainframe").contentWindow.location.href="${ctx}/right.html";
		Ext.getCmp("titleLabel").setText("手机后台管理 | <span id='logout'><a href='#' onclick='goIndex()'>回到首页</a> |  <a href='${ctx}/crmuser/logout' target='_top'>退出</a></span>",false);
		Ext.getCmp("exttreegridid").getRootNode().collapseChildNodes(true);
    }
	var second  =  10;
	var subsecond = null;
	
	
	function gotask(){
		if(confirm("确认离开当前页面,前往任务列表吗?")) {
			document.getElementById('downmsg_emessage').style.display = "none";
		   	Ext.getDom("mainframe").contentWindow.location.href="${ctx}/crmtask/intolist";
		} else{
			document.getElementById('downmsg_emessage').style.display = "none";
		}
	}
	function toMessageList(){
		   	Ext.getDom("mainframe").contentWindow.location.href="${ctx}/crmmessage/intomessagelist";
	}
	function toTaskList(){
		   	Ext.getDom("mainframe").contentWindow.location.href="${ctx}/crmtask/intolist";
	}
	// 部署的时候120秒请求一次  测试的时候10秒
	// 这个请求总是导致crm_task表被锁,所以暂时去掉,反正用的也不多 2012-8-10 俞升兵
	// 调整频率 3分钟刷新一次
     </script>
 </head>
 <body>
	  <!--弹出框-->

         <div class="Pop_up"  id="downmsg_emessage" style="display:none">
			 <div id="donwmsg_content" class="clearfix">
             <dl class="Pop_intro"> 
             <dd>
					<ul class="Pop_link">
					   <li><span class="tagged"><a  onclick='gotask();' target="mainframe">您刚收到<span id='taskspan'>0</span>条新任务,<span id='secondspan'>5</span>秒后消失</a></span></li>
					</ul>            
			 </dd>
             </dl>
        </div>

      </div>


 </body>
</html>